#include "stdio.h"
#include "highgui.h"
#include <string>
#include <iostream>

int main(void){
	IplImage* img1;
	IplImage* img2;
	int i;
	int iImageCountS = 201;
	int iImageCountE = 1700;
	char getFileImageName1[100];
	char getFileImageName2[100];
	char* imageNamePre = "out_";
	//char* imageName2 = "";
	char* imageExt = ".png";
	
	cvNamedWindow( "First overlap rectangle", CV_WINDOW_AUTOSIZE );	
	cvNamedWindow( "Biggest overlap rectangle", CV_WINDOW_AUTOSIZE );
	for( i=iImageCountS; i<iImageCountE; ++i ){
		if( i<10 ){
			sprintf( getFileImageName1, "%s/%s000%d%s", "Row3_LeftBack_out_old", imageNamePre, i, imageExt );			
			sprintf( getFileImageName2, "%s/%s000%d%s", "Row3_LeftBack_out", imageNamePre, i, imageExt );
		}else if(i<100){
			sprintf( getFileImageName1, "%s/%s00%d%s", "Row3_LeftBack_out_old", imageNamePre, i, imageExt );		
			sprintf( getFileImageName2, "%s/%s00%d%s", "Row3_LeftBack_out", imageNamePre, i, imageExt );
		}else if(i<1000){
			sprintf( getFileImageName1, "%s/%s0%d%s", "Row3_LeftBack_out_old", imageNamePre, i, imageExt );
			sprintf( getFileImageName2, "%s/%s0%d%s", "Row3_LeftBack_out", imageNamePre, i, imageExt );
		}else{
			sprintf( getFileImageName1, "%s/%s%d%s", "Row3_LeftBack_out_old", imageNamePre, i, imageExt );
			sprintf( getFileImageName2, "%s/%s%d%s", "Row3_LeftBack_out", imageNamePre, i, imageExt );
		}
		
		printf( "\n%s", getFileImageName1 );
		
		img1 = cvLoadImage( getFileImageName1, 1 );
		cvShowImage( "First overlap rectangle", img1 );
		img2 = cvLoadImage( getFileImageName2, 1 );
		cvShowImage( "Biggest overlap rectangle", img2 );
		
		char c = cvWaitKey(1000);
		if( c==27 ) break;
	}
	
	
	cvReleaseImage( &img1 );	
	cvReleaseImage( &img2 );
	
	return 0;
}
